<?php
/**
	Progress :
		- 25% 	> création de la fiche
		- 50%	> Manager ajoute les mesures (constat, diagnostic etc)
		- 75% 	> Chargé de qualité (valide)
		- 100% 	> Fiche clôturé
*/

if (isset($_POST['id_rating']) && isset($_POST['finding']) && 
	isset($_POST['diagnosis']) && isset($_POST['back']) && 
	isset($_POST['action_plan']) && isset($_POST['account_type']))
{
	require_once('Class/connexionDB.Class.php');

	$db 	= new connexionDB();

	$db->insertDebrief($_POST);
	
	if (isset($_POST['validate_debrief']))
	{
		$db->updateProgress(intval($_POST['id_rating']), 100);
	}
	else if (isset($_POST['deny_debrief']))
	{
		$db->updateProgress(intval($_POST['id_rating']), 100);	
		$db->updateDebrief(intval($_POST['id_rating']));
	}
	else
	{
		if ($_POST['account_type'] == 2)
		{
			$db->updateProgress($_POST['id_rating'], 50);	
		}
		if ($_POST['account_type'] == 3 || $_POST['account_type'] == 1)
		{
			$db->updateProgress($_POST['id_rating'], 25);	
		}	
	}
	
}

header('Location: show_rating.php?id='. $_POST['id_rating']);	
?>